package im.xz.cn.xiacore.entities.events;

import im.xz.cn.xiacore.XiaCore;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.plugin.Plugin;

public class creeper implements Listener {
    @EventHandler
    public void awa(EntityExplodeEvent event) {
        Plugin plugin = XiaCore.getPlugin(XiaCore.class);
        Location location = event.getLocation();
        try {
            if (event.getEntity().getType().equals(EntityType.CREEPER)) {
                try {
                    if (plugin.getConfig().getBoolean("disableCreeperBreak")) {
                        event.setCancelled(true);
                        location.createExplosion(3,false,false);
                    }
                }catch (NullPointerException ignore) {

                }


            }else if (event.getEntity().getType().equals(EntityType.TNT)) {
                try {
                    if (plugin.getConfig().getBoolean("disableTNTBreak")) {
                        event.setCancelled(true);
                        location.createExplosion(3,false,false);
                    }
                }catch (NullPointerException ignore) {

                }
            }
        }catch (NullPointerException ignore) {
        }
    }
}